package com.situ.day15Test;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.junit.Test;

public class Dome1 {
	@Test
	public void test() throws ClassNotFoundException {
		Class clazz = Class.forName("com.situ.day15Test.Person");
		Class clazz1 = Person.class;
		Person person = new Person();
		Class clazz2 = person.getClass();
		System.out.println(clazz.getName());
		System.out.println(clazz1.getSimpleName());
	}
	@Test
	public void  test1() {//构造函数
		Class clazz = Person.class;
		Constructor[] constructors = clazz.getDeclaredConstructors();
		for (Constructor constructor : constructors) {
			System.out.println(constructor);
			
		}
	}
	
	@Test
	public void test2() throws NoSuchMethodException, SecurityException {
		Class clazz = Person.class;
		
		Method[] methods = clazz.getDeclaredMethods();
		for (Method method : methods) {
			System.out.println(method);
		}
	}
	@Test
	public void test3() {
		Class clazz = Person.class;
		Field[] files = clazz.getDeclaredFields();
		for (Field field : files) {
			System.out.println(field);
		}
	}
	@Test
	public void  test4() throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {//构造函数
		Class clazz = Person.class;
		Constructor constructor	 = clazz.getConstructor(Integer.class,String.class);
		System.out.println(constructor);
		Person person = (Person)constructor.newInstance(new Object[]{1,"zhangsan"});
		System.out.println(person);
		}

	}
	

